package b.g.b;

import com.huawei.hms.analytics.core.crypto.AesCipher.AesLen;
import java.util.Arrays;
import java.util.Comparator;

/* compiled from: PriorityGoalRow */
public class f extends b {
    public int f = AesLen.ROOTKEY_COMPONET_LEN;
    public g[] g = new g[AesLen.ROOTKEY_COMPONET_LEN];
    public g[] h = new g[AesLen.ROOTKEY_COMPONET_LEN];
    public int i = 0;
    public b j = new b(this);

    /* compiled from: PriorityGoalRow */
    public class a implements Comparator<g> {
        public a(f fVar) {
        }

        public int compare(Object obj, Object obj2) {
            return ((g) obj).b - ((g) obj2).b;
        }
    }

    /* compiled from: PriorityGoalRow */
    public class b implements Comparable {
        public g a;

        public b(f fVar) {
        }

        public int compareTo(Object obj) {
            return this.a.b - ((g) obj).b;
        }

        public String toString() {
            String str = "[ ";
            if (this.a != null) {
                for (int i = 0; i < 9; i++) {
                    StringBuilder g = c.b.a.a.a.g(str);
                    g.append(this.a.h[i]);
                    g.append(" ");
                    str = g.toString();
                }
            }
            StringBuilder i2 = c.b.a.a.a.i(str, "] ");
            i2.append(this.a);
            return i2.toString();
        }
    }

    public f(c cVar) {
        super(cVar);
    }

    public void a(g gVar) {
        this.j.a = gVar;
        Arrays.fill(gVar.h, 0.0f);
        gVar.h[gVar.d] = 1.0f;
        m(gVar);
    }

    /* JADX WARNING: Missing block: B:22:0x0053, code skipped:
            if (r8 < r7) goto L_0x0057;
     */
    public b.g.b.g b(b.g.b.d r11, boolean[] r12) {
        /*
        r10 = this;
        r11 = 0;
        r0 = -1;
        r1 = 0;
        r2 = -1;
    L_0x0004:
        r3 = r10.i;
        if (r1 >= r3) goto L_0x005d;
    L_0x0008:
        r3 = r10.g;
        r4 = r3[r1];
        r5 = r4.b;
        r5 = r12[r5];
        if (r5 == 0) goto L_0x0013;
    L_0x0012:
        goto L_0x005a;
    L_0x0013:
        r5 = r10.j;
        r5.a = r4;
        r4 = 8;
        r6 = 1;
        if (r2 != r0) goto L_0x0039;
    L_0x001c:
        java.util.Objects.requireNonNull(r5);
    L_0x001f:
        if (r4 < 0) goto L_0x0035;
    L_0x0021:
        r3 = r5.a;
        r3 = r3.h;
        r3 = r3[r4];
        r7 = 0;
        r8 = (r3 > r7 ? 1 : (r3 == r7 ? 0 : -1));
        if (r8 <= 0) goto L_0x002d;
    L_0x002c:
        goto L_0x0035;
    L_0x002d:
        r3 = (r3 > r7 ? 1 : (r3 == r7 ? 0 : -1));
        if (r3 >= 0) goto L_0x0032;
    L_0x0031:
        goto L_0x0036;
    L_0x0032:
        r4 = r4 + -1;
        goto L_0x001f;
    L_0x0035:
        r6 = 0;
    L_0x0036:
        if (r6 == 0) goto L_0x005a;
    L_0x0038:
        goto L_0x0059;
    L_0x0039:
        r3 = r3[r2];
        java.util.Objects.requireNonNull(r5);
    L_0x003e:
        if (r4 < 0) goto L_0x0056;
    L_0x0040:
        r7 = r3.h;
        r7 = r7[r4];
        r8 = r5.a;
        r8 = r8.h;
        r8 = r8[r4];
        r9 = (r8 > r7 ? 1 : (r8 == r7 ? 0 : -1));
        if (r9 != 0) goto L_0x0051;
    L_0x004e:
        r4 = r4 + -1;
        goto L_0x003e;
    L_0x0051:
        r3 = (r8 > r7 ? 1 : (r8 == r7 ? 0 : -1));
        if (r3 >= 0) goto L_0x0056;
    L_0x0055:
        goto L_0x0057;
    L_0x0056:
        r6 = 0;
    L_0x0057:
        if (r6 == 0) goto L_0x005a;
    L_0x0059:
        r2 = r1;
    L_0x005a:
        r1 = r1 + 1;
        goto L_0x0004;
    L_0x005d:
        if (r2 != r0) goto L_0x0061;
    L_0x005f:
        r11 = 0;
        return r11;
    L_0x0061:
        r11 = r10.g;
        r11 = r11[r2];
        return r11;
        */
        throw new UnsupportedOperationException("Method not decompiled: b.g.b.f.b(b.g.b.d, boolean[]):b.g.b.g");
    }

    public void clear() {
        this.i = 0;
        this.b = 0.0f;
    }

    public boolean isEmpty() {
        return this.i == 0;
    }

    public void l(d dVar, b bVar, boolean z) {
        b bVar2 = bVar;
        g gVar = bVar2.a;
        if (gVar != null) {
            b.g.b.b.a aVar = bVar2.d;
            int e = aVar.e();
            for (int i = 0; i < e; i++) {
                g i2 = aVar.i(i);
                float a = aVar.a(i);
                b bVar3 = this.j;
                bVar3.a = i2;
                Object obj = 1;
                if (i2.a) {
                    for (int i3 = 0; i3 < 9; i3++) {
                        float[] fArr = bVar3.a.h;
                        fArr[i3] = (gVar.h[i3] * a) + fArr[i3];
                        if (Math.abs(fArr[i3]) < 1.0E-4f) {
                            bVar3.a.h[i3] = 0.0f;
                        } else {
                            obj = null;
                        }
                    }
                    if (obj != null) {
                        f.this.n(bVar3.a);
                    }
                    obj = null;
                } else {
                    for (int i4 = 0; i4 < 9; i4++) {
                        float f = gVar.h[i4];
                        if (f != 0.0f) {
                            f *= a;
                            if (Math.abs(f) < 1.0E-4f) {
                                f = 0.0f;
                            }
                            bVar3.a.h[i4] = f;
                        } else {
                            bVar3.a.h[i4] = 0.0f;
                        }
                    }
                }
                if (obj != null) {
                    m(i2);
                }
                this.b = (bVar2.b * a) + this.b;
            }
            n(gVar);
        }
    }

    public final void m(g gVar) {
        g[] gVarArr;
        int i = this.i + 1;
        g[] gVarArr2 = this.g;
        if (i > gVarArr2.length) {
            gVarArr = (g[]) Arrays.copyOf(gVarArr2, gVarArr2.length * 2);
            this.g = gVarArr;
            this.h = (g[]) Arrays.copyOf(gVarArr, gVarArr.length * 2);
        }
        gVarArr = this.g;
        int i2 = this.i;
        gVarArr[i2] = gVar;
        i2++;
        this.i = i2;
        if (i2 > 1 && gVarArr[i2 - 1].b > gVar.b) {
            int i3;
            i = 0;
            i2 = 0;
            while (true) {
                i3 = this.i;
                if (i2 >= i3) {
                    break;
                }
                this.h[i2] = this.g[i2];
                i2++;
            }
            Arrays.sort(this.h, 0, i3, new a(this));
            while (i < this.i) {
                this.g[i] = this.h[i];
                i++;
            }
        }
        gVar.a = true;
        gVar.a(this);
    }

    public final void n(g gVar) {
        int i = 0;
        while (i < this.i) {
            if (this.g[i] == gVar) {
                while (true) {
                    int i2 = this.i;
                    if (i < i2 - 1) {
                        g[] gVarArr = this.g;
                        int i3 = i + 1;
                        gVarArr[i] = gVarArr[i3];
                        i = i3;
                    } else {
                        this.i = i2 - 1;
                        gVar.a = false;
                        return;
                    }
                }
            }
            i++;
        }
    }

    public String toString() {
        StringBuilder i = c.b.a.a.a.i("", " goal -> (");
        i.append(this.b);
        i.append(") : ");
        String stringBuilder = i.toString();
        for (int i2 = 0; i2 < this.i; i2++) {
            this.j.a = this.g[i2];
            i = c.b.a.a.a.g(stringBuilder);
            i.append(this.j);
            i.append(" ");
            stringBuilder = i.toString();
        }
        return stringBuilder;
    }
}
